package com.example.springboot_shiro.utils;

import java.util.Random;

public class SaltUtils {
    /**
     * 生成salt的静态方法
     */
    public  static String getSalt(int n){
        char[] chars="qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM1234567890!@#$%^&*(){}:<>?/".toCharArray();
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<n;i++){
            char aChar=chars[new Random().nextInt(chars.length)];
            sb.append(aChar);
        }
        return sb.toString();
    }
    public static void main(String[] args){
        String salt = getSalt(6);
    System.out.println(salt);
    }

}
